package com.base.social.exception;

import com.base.core.enums.SystemCodeEnum;
import com.base.social.config.AuthSource;

public class AuthRuntimeException extends RuntimeException {

    private int errorCode;
    private String errorMsg;

    public AuthRuntimeException(String errorMsg) {
        this(SystemCodeEnum.FAILURE.getCode(), errorMsg);
    }

    public AuthRuntimeException(String errorMsg, AuthSource source) {
        this(SystemCodeEnum.FAILURE.getCode(), errorMsg, source);
    }

    public AuthRuntimeException(int errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public AuthRuntimeException(SystemCodeEnum status) {
        this(status.getCode(), status.getMessage());
    }

    public AuthRuntimeException(int errorCode, String errorMsg, AuthSource source) {
        this(errorCode, String.format("%s [%s]", errorMsg, source.getName()));
    }

    public AuthRuntimeException(SystemCodeEnum status, AuthSource source) {
        this(status.getCode(), status.getMessage(), source);
    }

    public AuthRuntimeException(String message, Throwable cause) {
        super(message, cause);
    }

    public AuthRuntimeException(Throwable cause) {
        super(cause);
    }

    public int getErrorCode() {
        return errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }
}
